﻿<sap:ActivityDesigner x:Class="WFDataBaseProject.UCAsyncExecuteSqlActivityDesigner"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:helpers="clr-namespace:WFDataBaseProject.Helpers"
    xmlns:s="clr-namespace:System;assembly=mscorlib"                  
    xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
    xmlns:sapc="clr-namespace:System.Activities.Presentation.Converters;assembly=System.Activities.Presentation"                 
    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation">
    <sap:ActivityDesigner.Resources>
        <!--Converters-->
        <sapc:ArgumentToExpressionConverter x:Key="argumentToExpressionConverter" />
        <!--<helpers:ToStringConverter x:Key="toStringConverter" />
        <helpers:VisibilityExtension x:Key="visibilityConverter" />-->
        <!--Extensions-->
        <!--expanded mode data template-->
        <DataTemplate x:Key="expanded">
            <StackPanel>
                <!--Connection type-->
                <TextBlock Text="Connection type (TypeOfConnection): "/>
                <sapv:ExpressionTextBox OwnerActivity="{Binding Path=ModelItem}"
                                DefaultValue="TypeOfConnection.SqlServerConnection"
                                HintText="Enter the connection type here..."
              Expression="{Binding Path=ModelItem.ConnectionType,Mode=TwoWay,
            Converter={StaticResource argumentToExpressionConverter},ConverterParameter=In}" 
                                ExpressionType="{x:Type helpers:TypeOfConnection}"/>
                <!--Connection string-->
                <TextBlock Text="Connection string: "/>
                <sapv:ExpressionTextBox Grid.Column="0" OwnerActivity="{Binding Path=ModelItem}"
                                  HintText="Enter the connection string here..."
                                  DefaultValue="Data Source=.;Initial Catalog=Test;Integrated Security=True"
                                  Expression="{Binding Path=ModelItem.ConnectionString,Mode=TwoWay,
                                  Converter={StaticResource argumentToExpressionConverter},ConverterParameter=In}" 
                                  ExpressionType="s:String"
                                />
                <!--Source location-->
                <TextBlock Text="Source location (SqlSourceLocation): "/>
                <sapv:ExpressionTextBox Name="txtSourceLocation"
                                OwnerActivity="{Binding Path=ModelItem}"
                                HintText="Enter the query location here..."
              Expression="{Binding Path=ModelItem.SourceLocation,Mode=TwoWay,
            Converter={StaticResource argumentToExpressionConverter},ConverterParameter=In}" 
                                ExpressionType="{x:Type helpers:SqlSourceLocation}"/>
                <!--File name-->
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="File name: " Name="txtfilename"  Grid.Row="0"  />
                    <sapv:ExpressionTextBox Grid.Row="1" 
                                OwnerActivity="{Binding Path=ModelItem}"
                                HintText="Enter the path here..." Name="txt"
                                DefaultValue="SqlSourceLocation.TextFile"
                                Expression="{Binding Path=ModelItem.FileName,Mode=TwoWay,
                                Converter={StaticResource argumentToExpressionConverter},ConverterParameter=In}" 
                                ExpressionType="s:String">
                    </sapv:ExpressionTextBox>
                </Grid>
                <!--Query-->
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="Query: " Grid.Row="0"/>
                    <sapv:ExpressionTextBox Name="txtQuery" OwnerActivity="{Binding Path=ModelItem}" Grid.Row="1"
                                HintText="Enter the query body here..."
                            
                                Expression="{Binding Path=ModelItem.Query,Mode=TwoWay,
                                Converter={StaticResource argumentToExpressionConverter},ConverterParameter=In}" 
                                ExpressionType="s:String"/>
                </Grid>

                <!--Returned type-->
                <TextBlock Text="Returned type (TypeOfReturn): "/>
                <sapv:ExpressionTextBox OwnerActivity="{Binding Path=ModelItem}"
                                DefaultValue="TypeOfReturn.Request"
                                HintText="Enter the returned type here..."
              Expression="{Binding Path=ModelItem.ReturnedType  ,Mode=TwoWay,
            Converter={StaticResource argumentToExpressionConverter},ConverterParameter=In}" 
                                ExpressionType="{x:Type helpers:TypeOfReturn}"/>
            </StackPanel>
        </DataTemplate>
        <!--Collapsed-->
        <DataTemplate x:Key="collapsed">
            <TextBlock Text="Collapsed mode"/>
        </DataTemplate>
        <!--Style for activity designer-->
        <Style x:Key="displaymodestyle" TargetType="{x:Type ContentPresenter}">
            <Setter Property="ContentTemplate" Value="{DynamicResource expanded}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=ShowExpanded}" Value="false">
                    <Setter Property="ContentTemplate" Value="{DynamicResource collapsed}"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </sap:ActivityDesigner.Resources>
    <sap:ActivityDesigner.Icon>
        <DrawingBrush>
            <DrawingBrush.Drawing>
                <ImageDrawing>
                    <ImageDrawing.Rect>
                        <Rect Location="0,0" Size="16,16" ></Rect>
                    </ImageDrawing.Rect>
                    <ImageDrawing.ImageSource>
                        <BitmapImage UriSource="Images/execsql.jpg" ></BitmapImage>
                    </ImageDrawing.ImageSource>
                </ImageDrawing>
            </DrawingBrush.Drawing>
        </DrawingBrush>
    </sap:ActivityDesigner.Icon>
    <Grid>
        <ContentPresenter Style="{DynamicResource displaymodestyle}" Content="{Binding}" />
    </Grid>
</sap:ActivityDesigner>
